//
//  Date+Ex.swift
//  TSLiveWallpaper
//
//  Created by 100Years on 2024/12/20.
//

public extension Date {
    private static var HmsFormatter: DateFormatter {
        let formatter = DateFormatter()
        formatter.dateFormat = "HH:mm:ss:SSS"
        formatter.locale = Locale(identifier: "en")
        return formatter
    }
    
    static var hmsString: String {
        return HmsFormatter.string(from: Date())
    }
    
    static var timestampString: String {
        return String(timestampInt)
    }
    
    
    static var timestampInt: Int {
        return Int(Date().timeIntervalSince1970)
    }
    
    var dateTimeString:String {
        // 创建 DateFormatter 实例
        let dateFormatter = DateFormatter()
        // 设置日期格式
        dateFormatter.dateFormat = "MMMM d, yyyy 'At' h:mm a"
        // 设置本地化信息，确保月份名称和 AM/PM 显示正确
        dateFormatter.locale = Locale(identifier: "en_US")
        // 将 Date 对象转换为字符串
        let dateString = dateFormatter.string(from: self)
        
        return dateString
    }
    
    
    var dateDayString:String {
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "yyyyMMdd"
        let dateString = dateFormatter.string(from: self)
        return dateString
    }
}
